package com.yz.newspaper.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yz.newspaper.pojo.po.Duty;
import com.yz.newspaper.mapper.DutyMapper;
import com.yz.newspaper.pojo.unitPo.PageBean;
import com.yz.newspaper.pojo.vo.DutyVo;
import com.yz.newspaper.service.IDutyService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 值班表 服务实现类
 * </p>
 *
 * @author author
 * @since 2024-04-29
 */
@Service
public class DutyServiceImpl extends ServiceImpl<DutyMapper, Duty> implements IDutyService {

    @Autowired
    private DutyMapper baseMapper;

    @Override
    public PageBean getDutyList(String username, Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<DutyVo> list = baseMapper.getDutyList(username);
        PageInfo pageInfo = new PageInfo(list);
        PageBean<Duty> pageBean = new PageBean<>();
        pageBean.setTotal(pageInfo.getTotal());
        pageBean.setRows(pageInfo.getList());
        return pageBean;
    }
}
